package com.yiwei.hdb.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yiwei.hdb.R;
import com.yiwei.hdb.constant.Const;
import com.yiwei.hdb.fragment.V3XueXinLoginFragment;
import com.yiwei.hdb.fragment.V3XueXinRegisterFragment;
import com.yiwei.hdb.model.CertificationBasicsModel;
import com.yiwei.hdb.model.DealBeforeV3Model;
import com.yiwei.hdb.util.IdentityStepUtil;
import com.yiwei.hdb.view.CustomViewPager;
import com.yiwei.hdb.view.Dialog;
import com.yiwei.hdb.view.FlowViewHorizontal;
import com.yiwei.hdb.view.HomeViewPager;
import com.yiwei.hdb.view.V19FrameLayout;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2018/6/10.
 */

public class V3XueXinIdentityActivity extends BaseActivity {
    @BindView(R.id.btn_back)
    ImageView btnBack;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.txt_right)
    TextView txtRight;
    @BindView(R.id.layout_title)
    V19FrameLayout layoutTitle;
    @BindView(R.id.step_view)
    FlowViewHorizontal stepView;
//    @BindView(R.id.btn_login)
//    TextView btnLogin;
//    @BindView(R.id.btn_register)
//    TextView btnRegister;
//    @BindView(R.id.view_login)
//    View viewLogin;
//    @BindView(R.id.view_register)
//    View viewRegister;
    @BindView(R.id.pager)
    CustomViewPager pager;
    private Unbinder unbinder;
    private String bizType = "xuexin";
    public IdentityStepUtil stepUtil;
    private ArrayList<CertificationBasicsModel.DataBean> oneKeyData;
    private ArrayList<DealBeforeV3Model.DataBean.UplistsBean> SomeKeyData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xuexin_identity_v3);
        initBar();
        unbinder = ButterKnife.bind(this);
        init();
    }

    private void init() {
        txtTitle.setText("学信网认证");
        oneKeyData = getIntent().getParcelableArrayListExtra(Const.KEY.ONE_KEY);

        SomeKeyData = getIntent().getParcelableArrayListExtra(Const.KEY.SOME_IDENTITY_KEY);
        stepUtil = new IdentityStepUtil(this);
        stepUtil.setIdentityData(bizType, txtTitle, stepView, oneKeyData, SomeKeyData);

        Fragment[] fragments = new Fragment[]{new V3XueXinLoginFragment()};
        pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments[position];
            }

            @Override
            public int getCount() {
                return fragments.length;
            }
        });
    }

    private void showDialog() {
        Dialog.showV3DefaultDialog(this, "提示", "认证还未完成\n您确定要退出吗？", "取消", "确定", new Dialog.DialogDefaultClickListener() {
            @Override
            public void confirm() {
                finish();
            }

            @Override
            public void cancel() {

            }
        });
    }


    @Override
    public void onBackPressed() {
        showDialog();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        stepUtil = null;
        unbinder.unbind();
        unbinder = null;
    }

//    private void selectOne() {
//        btnLogin.setTextColor(0xff4C81FF);
//        viewLogin.setVisibility(View.VISIBLE);
//
//        btnRegister.setTextColor(0xff616185);
//        viewRegister.setVisibility(View.GONE);
//        pager.setCurrentItem(0);
//    }
//
//    private void selectTwo() {
//        btnRegister.setTextColor(0xff4C81FF);
//        viewRegister.setVisibility(View.VISIBLE);
//
//        btnLogin.setTextColor(0xff616185);
//        viewLogin.setVisibility(View.GONE);
//        pager.setCurrentItem(1);
//    }

    @OnClick({R.id.btn_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
//                stepUtil.goToNext();
                showDialog();
                break;
//            case R.id.btn_login:
//                selectOne();
//                break;
//            case R.id.btn_register:
//                selectTwo();
//                break;
        }
    }
}
